package org.sanmao.wyj.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.sanmao.wyj.domain.User;
import org.sanmao.wyj.domain.Worker;
import org.springframework.security.core.parameters.P;

import java.util.List;

@Mapper
public interface WorkerDao extends BaseMapper<Worker> {
    @Select("select * from worker where username = #{username} and password = #{password}")
    Worker findWorkerByUsernameAndPassword(@Param("username")String username, @Param("password") String password);

    @Select("select * from worker where name like CONCAT('%',#{name},'%')")
    IPage<Worker> findWorkersByName(IPage<Worker>page, @Param("name")String name);

    @Select("select * from worker where username = #{username} and idcard = #{idcard}")
    Worker findWorkersByUsernameAndIdcad(@Param("username") String username, @Param("idcard") String idcard);

    @Select("select w.*,count(o.wid) as order_count from worker as w left join orders as o on w.wid = o.wid where w.wid = #{wid}")
    Worker findMe(int wid);

    @Select("select * from worker where username = #{username}")
    Worker findWorkerByUsername(String username);
}
